﻿using Orchard.ContentManagement;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Orchard.ContentManagement.FieldStorage.InfosetStorage;
using Orchard.Environment.Extensions;

namespace F2B.Orchard.Schedule.Models
{
    public class ScheduleSettingsPart : ContentPart
    {
        public TimeSpan DefaultStartTime
        {
            get
            {
                string current = this.As<InfosetPart>().Get<ScheduleSettingsPart>("DefaultStartTime") ?? "480";
                return TimeSpan.FromMinutes(Convert.ToInt32(current));
            }
            set { this.As<InfosetPart>().Set<ScheduleSettingsPart>("DefaultStartTime", ((int)value.TotalMinutes).ToString()); }
        }

        public TimeSpan DefaultDuration
        {
            get
            {
                string current = this.As<InfosetPart>().Get<ScheduleSettingsPart>("DefaultDuration") ?? "60";
                return TimeSpan.FromMinutes(Convert.ToInt32(current));
            }
            set { this.As<InfosetPart>().Set<ScheduleSettingsPart>("DefaultDuration", ((int)value.TotalMinutes).ToString()); }
        }
    }
}